﻿#修改或创建用户收货地址


use strict;

sub changeAddress
{
	my $number;
	($number) = @_;
	#打印说明信息
	&myprint("description",$number);
	
	#读取公共资源
	my @survey = &config("","sql");
	#管理后台地址
	my $mgt_addr = &config("","mgt_addr");
	#手机服务地址
	my $mob_addr = &config("","mob_addr");
	#开放平台地址
	my $open_addr = &config("","open_addr");
	#wap地址
	my $wap_addr = &config("","wap_addr");
	
	#并发量
	my $bingfa = 1;			
	#获取测试数据	$data{'字段名字'}->[第几行数据的下标]  $data{'userAccount'}->[n] 
	my %data = &readData('1411751731_10_survey_0305.txt',',');
	
	
	#单次循环并发
	my $doBinfa = 0;
	my @threadHead;
	my ($wapBrowser, $LotteryReturn, $mobrowser, $accessToken);
	my $count = 0;
	for my $index (0..$data{'maxDataLine'}){
		my $useraccount = $data{'account'}->[$index];
		#计数器
		$count++;
		print "NO $count $useraccount \n";
		#创建抽奖线程
#		push @threadHead ,threads->create(
#			sub{
				#手机登录
				($mobrowser,$accessToken) = &moblogin($mob_addr,$useraccount,'MTExMTExMTE=');
				next unless($mobrowser);
				print "Token:($accessToken) \n";
				#收货地址创建或修改
				#收货地址信息配置
				my %addressPost = (
					#"id" => "",
					"province" => "01",
					"city" => "0117",
					"district" => "011701",
					"address" => $useraccount.'-东城西路水车岭6巷6号',
					"receiver" => "杨小测",
					"postcode" => "200126",
					"cellphone" => "13564324375",
					#"aeracode" => "",
					#"phone" => "",
					#"subnum" => "",
					"isDefault" => "1",
				);
				
				&useraddress($mobrowser,$mob_addr,$accessToken,\%addressPost)
				
				
				#逐个登录wap
				#$wapBrowser = &wapLogin($wap_addr,$accessToken);
				#print "wapBrowser:($wapBrowser) \n";
				#执行积分购买
				#$LotteryReturn = &executeLottery($wap_addr, \@survey, $wapBrowser, $accessToken);
				#myprint("encode", "LotteryReturn:($LotteryReturn) \n");
#			}
#		);
#		$doBinfa++;
#		
#		if($doBinfa eq $bingfa){
#			for(@threadHead){
#				$_->join();
#			}
#			$doBinfa = 0;
#			@threadHead = ();
#			print "--do join--\n";
#		}
	}
	
	



	return -1;

}
1;